| Conditions | 5 |
| Paths | 4 |
| Total Lines | 85 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | // BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. |
||
| 17 | $(document).on('turbolinks:load', function(){ |
||
| 18 | var controller = $("body").data('controller'); |
||
| 19 | var action = $("body").data('action'); |
||
| 20 | |||
| 21 | // Only run on the admins page. |
||
| 22 | if (controller == "admins" && action == "index") { |
||
| 23 | // show the modal with the correct form action url |
||
| 24 | $(".delete-user").click(function(data){ |
||
| 25 | var uid = $(data.target).closest("tr").data("user-uid") |
||
| 26 | var url = $("body").data("relative-root") |
||
| 27 | if (!url.endsWith("/")) { |
||
| 28 | url += "/" |
||
| 29 | } |
||
| 30 | url += "u/" + uid |
||
| 31 | $("#delete-confirm").parent().attr("action", url) |
||
| 32 | }) |
||
| 33 | |||
| 34 | //clear the role filter if user clicks on the x |
||
| 35 | $(".clear-role").click(function() { |
||
| 36 | var search = new URL(location.href).searchParams.get('search') |
||
|
|
|||
| 37 | |||
| 38 | var url = window.location.pathname + "?page=1" |
||
| 39 | |||
| 40 | if (search) { |
||
| 41 | url += "&search=" + search |
||
| 42 | } |
||
| 43 | |||
| 44 | window.location.replace(url); |
||
| 45 | }) |
||
| 46 | |||
| 47 | /* COLOR SELECTORS */ |
||
| 48 | |||
| 49 | $('#colorinput-regular').ColorPicker({ |
||
| 50 | onBeforeShow: function () { |
||
| 51 | var colour = rgb2hex($("#colorinput-regular").css("background-color")) |
||
| 52 | |||
| 53 | $(this).ColorPickerSetColor(colour); |
||
| 54 | }, |
||
| 55 | onSubmit: function(_hsb, hex) { |
||
| 56 | $.post($("#coloring-path-regular").val(), {color: '#' + hex}).done(function() { |
||
| 57 | location.reload() |
||
| 58 | }); |
||
| 59 | }, |
||
| 60 | }); |
||
| 61 | |||
| 62 | $('#colorinput-lighten').ColorPicker({ |
||
| 63 | onBeforeShow: function () { |
||
| 64 | var colour = rgb2hex($("#colorinput-lighten").css("background-color")) |
||
| 65 | |||
| 66 | $(this).ColorPickerSetColor(colour); |
||
| 67 | }, |
||
| 68 | onSubmit: function(_hsb, hex) { |
||
| 69 | $.post($("#coloring-path-lighten").val(), {color: '#' + hex}).done(function() { |
||
| 70 | location.reload() |
||
| 71 | }); |
||
| 72 | }, |
||
| 73 | }); |
||
| 74 | |||
| 75 | $('#colorinput-darken').ColorPicker({ |
||
| 76 | onBeforeShow: function () { |
||
| 77 | var colour = rgb2hex($("#colorinput-darken").css("background-color")) |
||
| 78 | |||
| 79 | $(this).ColorPickerSetColor(colour); |
||
| 80 | }, |
||
| 81 | onSubmit: function(_hsb, hex) { |
||
| 82 | $.post($("#coloring-path-darken").val(), {color: '#' + hex}).done(function() { |
||
| 83 | location.reload() |
||
| 84 | }); |
||
| 85 | }, |
||
| 86 | }); |
||
| 87 | } |
||
| 88 | |||
| 89 | // Only run on the admins edit user page. |
||
| 90 | if (controller == "admins" && action == "edit_user") { |
||
| 91 | $(".setting-btn").click(function(data){ |
||
| 92 | var url = $("body").data("relative-root") |
||
| 93 | if (!url.endsWith("/")) { |
||
| 94 | url += "/" |
||
| 95 | } |
||
| 96 | url += "admins?setting=" + data.target.id |
||
| 97 | |||
| 98 | window.location.href = url |
||
| 99 | }) |
||
| 100 | } |
||
| 101 | }); |
||
| 102 | |||
| 130 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.